home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / Other Langs / Tickle-4.0 (tcl) / tcl / extend / tests / convlib.test < prev    next >
Encoding:
Text File  |  1993-11-07  |  2.5 KB  |  79 lines  |  [TEXT/MPS ]

  1. #
  2. # convlib.test
  3. #
  4. # Tests for tcl.tlib convert_lib routine.
  5. #---------------------------------------------------------------------------
  6. # Copyright 1992-1993 Karl Lehenbauer and Mark Diekhans.
  7. #
  8. # Permission to use, copy, modify, and distribute this software and its
  9. # documentation for any purpose and without fee is hereby granted, provided
  10. # that the above copyright notice appear in all copies.  Karl Lehenbauer and
  11. # Mark Diekhans make no representations about the suitability of this
  12. # software for any purpose.  It is provided "as is" without express or
  13. # implied warranty.
  14. #------------------------------------------------------------------------------
  15. # $Id: convlib.test,v 2.2 1993/07/20 08:35:45 markd Exp $
  16. #------------------------------------------------------------------------------
  17. #
  18.  
  19. if {[info procs test] == ""} then {source testlib.tcl}
  20. eval $SAVED_UNKNOWN
  21.  
  22. catch {unlink -nocomplain [glob :convlib.tmp:*]}
  23. catch {rmdir :convlib.tmp}
  24. mkdir :convlib.tmp
  25.  
  26. # Create a temporary source files and generate an index.
  27.  
  28. loop num 0 5 {
  29.     set fh [open :convlib.tmp:tmp${num}.tcl w]
  30.     puts $fh "proc LoadProc${num}A {} {return @LoadProc${num}A@}"
  31.     puts $fh "proc LoadProc${num}B {} {return @LoadProc${num}B@}"
  32.     close $fh
  33. }
  34.  
  35. set fh [open :convlib.tmp:init.tcl w]
  36. puts $fh "proc InitTcl {} {return @InitTcl@}"
  37. close $fh
  38.  
  39. auto_mkindex :convlib.tmp *.tcl
  40.  
  41. # Proc that validates the library by executing procs out of it.
  42.  
  43. proc LibValidate {testid testname} {
  44.     loop num 0 5 {
  45.         Test $testid.1 $testname {
  46.             LoadProc${num}A
  47.         } 0 "@LoadProc${num}A@"
  48.         Test $testid.2 $testname {
  49.             LoadProc${num}B
  50.         } 0 "@LoadProc${num}B@"
  51.         Test $testid.3 $testname {
  52.             InitTcl
  53.         } 1 {invalid command name "InitTcl"}
  54.     }
  55. }
  56.  
  57. #
  58. # Now convert and load the library, see if we can actually use it.
  59. #
  60.  
  61. Test convlib-1.1 {Convert library tests} {
  62.     unlink -nocomplain {:convlib.tmp:tmp.tlib :convlib.tmp:tmp.tndx}
  63.     convert_lib :convlib.tmp:tclIndex :convlib.tmp:tmp  "init.tcl"
  64.     list [file exists :convlib.tmp:tmp.tlib] [file exists :convlib.tmp:tmp.tndx]
  65. } 0 {1 1}
  66.  
  67. Test convlib-1.2 {Convert library tests} {
  68.     unlink -nocomplain {:convlib.tmp:tmp.tlib :convlib.tmp:tmp.tndx}
  69.     convert_lib :convlib.tmp:tclIndex :convlib.tmp:tmp.tlib "init.tcl"
  70.     list [file exists :convlib.tmp:tmp.tlib] [file exists :convlib.tmp:tmp.tndx]
  71. } 0 {1 1}
  72.  
  73. loadlibindex :convlib.tmp:tmp.tlib
  74. LibValidate convlib-1.3 {Convert library tests}
  75.  
  76. catch {unlink -nocomplain [glob :convlib.tmp:*]}
  77. catch {rmdir :convlib.tmp}
  78. rename unknown {}
  79.